﻿using Gateway.Common.Entity;
using Gateway.Common.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Gateway.Domain.EFCore.Configuration
{
    public class EntityWithOperatorStatusConfiguration<T> : EntityWithOperatorConfiguration<T> where T : EntityWithOperatorStatusBase
    {
        public override void Configure(EntityTypeBuilder<T> builder)
        {
            base.Configure(builder);
            builder.Property(x => x.Deleted).IsRequired().HasMaxLength(1).HasComment("是否删除").HasConversion(x => x.Value, x => BooleanStatusEnum.FromValue(x));
            builder.Property(x => x.Disabled).IsRequired().HasMaxLength(1).HasComment("是否禁用").HasConversion(x => x.Value, x => BooleanStatusEnum.FromValue(x));
        }
    }
}